/**
* 作者: clz
* 日期: 2025-04-05 11:28:08
* 备注: 联盟信息
*/
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.commondata.union.UnionMain;
import com.motu.monstercity.server.game.logic.GameUser;
import com.motu.monstercity.server.game.logic.UnionManager;
import com.motu.vertx.module.utility.toolset.TimeUtils;

public class UnionInfo extends UnionInfoModel {

	public static final int FAMILY_LIMIT0 = 0; // 无限制
	public static final int FAMILY_LIMIT1 = 1; // 需验证


	public UnionInfo() {
		super();
	}

	public UnionInfo(String name, long userId, String userName, int serverId,int icon1,int icon2) {
		putName(name);
		putCreateTime(TimeUtils.getCurTime());
		putCreateUserId(userId);
		putMasterId(userId);
		putMasterName(userName);
		putServerId(serverId);
		putLevel(1);
		String decorate = icon1 + "-" + icon2;
		putIcon(decorate);
	}

	public void addExp(int value) {
		int curExp = getExp();
		int newExp = curExp + value;
		//判断是否可以升级
		UnionMain  unionMain = UnionManager.getUnionMain(getLevel());
		int needExp = unionMain.getExp();
		if (newExp >= needExp) {
			//满足升级条件
			addLevel(1);
			putExp(curExp - unionMain.getExp());
			UnionManager.updateUnionBoxInfo(getId(), getLevel()); // 更新联盟宝箱
			putExp(newExp - needExp);
		}else {
			putExp(newExp);
		}
	}

}
